$(document).ready(function () {
    layui.use('form', function () {
        var form = layui.form;
        form.render();

        getHousehold();

    });
});

function getHousehold() {

    var id = $('#id').val();

    ajax(
        "/admin/household/getHousehold", "POST",
        { householdId: id }
        ,true, true, false
    ).done(function (returnData) {

        $("input[name='householdId']").val(returnData.householdId);
        $("input[name='householdNo']").val(returnData.householdNo);
        $("input[name='householdName']").val(returnData.householdName);
        $(":radio[name='householdSex'][value='" + returnData.householdSex + "']").prop("checked", true);
        $("input[name='householdPhone']").val(returnData.householdPhone);
        $("input[name='householdEmail']").val(returnData.householdEmail);
        $("input[name='householdJob']").val(returnData.householdJob);
        $("input[name='householdAge']").val(returnData.householdAge);
        $("input[name='householdIDCard']").val(returnData.householdIDCard);
        $("input[name='householdEducation']").val(returnData.householdEducation);
        $("input[name='householdHobby']").val(returnData.householdHobby);
        $("input[name='householdCreateTime']").val(returnData.householdCreateTime);
        $("input[name='householdPositionName']").val(returnData.householdPositionName);
        $("input[name='householdPositionId']").val(returnData.householdPositionId);

        form.render();

    });

}

function editHousehold() {

    var formJSON = $("#household-submit-form").serializeObject();

    // 编辑住户
    ajax(
        "/admin/household/editHousehold", "POST",
        formJSON, true, true, true
    ).done(function () {
        loadingPage("/admin/household/household");
    });

}

